package com.chan.web.controller.cd;

import java.util.List;

import com.chan.common.config.ChanConfig;
import com.chan.common.utils.StringUtils;
import com.chan.common.utils.file.FileUtils;
import com.chan.web.controller.common.CommonController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.chan.domain.CdDetailegather;
import com.chan.service.ICdDetailegatherService;
import com.chan.common.annotation.Log;
import com.chan.common.core.controller.BaseController;
import com.chan.common.core.domain.AjaxResult;
import com.chan.common.core.page.TableDataInfo;
import com.chan.common.enums.BusinessType;
import com.chan.common.utils.poi.ExcelUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 信息收集Controller
 *
 * @author chan
 * @date 2024-04-29
 */
@Controller
@RequestMapping("/cd/detailegather")
public class CdDetailegatherController extends BaseController
{
    private String prefix = "cd/detailegather";
    private static final Logger log = LoggerFactory.getLogger(CdDetailegatherController.class);

    @Autowired
    private ICdDetailegatherService cdDetailegatherService;

    @RequiresPermissions("cd:detailegather:view")
    @GetMapping()
    public String detailegather()
    {
        return prefix + "/detailegather";
    }

    /**
     * 查询信息收集列表
     */
    @RequiresPermissions("cd:detailegather:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CdDetailegather cdDetailegather)
    {
        startPage();
        List<CdDetailegather> list = cdDetailegatherService.selectCdDetailegatherList(cdDetailegather);
        return getDataTable(list);
    }

    /**
     * 导出信息收集列表
     */
    @RequiresPermissions("cd:detailegather:export")
    @Log(title = "信息收集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CdDetailegather cdDetailegather)
    {
        List<CdDetailegather> list = cdDetailegatherService.selectCdDetailegatherList(cdDetailegather);
        ExcelUtil<CdDetailegather> util = new ExcelUtil<CdDetailegather>(CdDetailegather.class);
        return util.exportExcel(list, "信息收集数据");
    }

    /**
     * 新增信息收集
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存信息收集
     */
    @RequiresPermissions("cd:detailegather:add")
    @Log(title = "信息收集", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CdDetailegather cdDetailegather)
    {
        return toAjax(cdDetailegatherService.insertCdDetailegather(cdDetailegather));
    }

    /**
     * 修改信息收集
     */
    @RequiresPermissions("cd:detailegather:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CdDetailegather cdDetailegather = cdDetailegatherService.selectCdDetailegatherById(id);
        mmap.put("cdDetailegather", cdDetailegather);
        return prefix + "/edit";
    }

    /**
     * 修改保存信息收集
     */
    @RequiresPermissions("cd:detailegather:edit")
    @Log(title = "信息收集", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CdDetailegather cdDetailegather)
    {
        return toAjax(cdDetailegatherService.updateCdDetailegather(cdDetailegather));
    }

    /**
     * 删除信息收集
     */
    @RequiresPermissions("cd:detailegather:remove")
    @Log(title = "信息收集", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(cdDetailegatherService.deleteCdDetailegatherByIds(ids));
    }



}
